<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>window.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-painting-painterpaths-example.html">Painter Paths Example</a></td><td >window.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">window.cpp 示例文件</h1>
<span class="subtitle">painting/painterpaths/window.cpp</span>
<!-- $$$painting/painterpaths/window.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &quot;renderarea.h&quot;</span>
  <span class="preprocessor">#include &quot;window.h&quot;</span>

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="preprocessor">#include &lt;qmath.h&gt;</span>

  Window<span class="operator">::</span>Window()
  {
      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> rectPath;
      rectPath<span class="operator">.</span>moveTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">30.0</span>);
      rectPath<span class="operator">.</span>lineTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">30.0</span>);
      rectPath<span class="operator">.</span>lineTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">70.0</span>);
      rectPath<span class="operator">.</span>lineTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">70.0</span>);
      rectPath<span class="operator">.</span>closeSubpath();

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> roundRectPath;
      roundRectPath<span class="operator">.</span>moveTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">35.0</span>);
      roundRectPath<span class="operator">.</span>arcTo(<span class="number">70.0</span><span class="operator">,</span> <span class="number">30.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">0.0</span><span class="operator">,</span> <span class="number">90.0</span>);
      roundRectPath<span class="operator">.</span>lineTo(<span class="number">25.0</span><span class="operator">,</span> <span class="number">30.0</span>);
      roundRectPath<span class="operator">.</span>arcTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">30.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">90.0</span><span class="operator">,</span> <span class="number">90.0</span>);
      roundRectPath<span class="operator">.</span>lineTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">65.0</span>);
      roundRectPath<span class="operator">.</span>arcTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">60.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">180.0</span><span class="operator">,</span> <span class="number">90.0</span>);
      roundRectPath<span class="operator">.</span>lineTo(<span class="number">75.0</span><span class="operator">,</span> <span class="number">70.0</span>);
      roundRectPath<span class="operator">.</span>arcTo(<span class="number">70.0</span><span class="operator">,</span> <span class="number">60.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">10.0</span><span class="operator">,</span> <span class="number">270.0</span><span class="operator">,</span> <span class="number">90.0</span>);
      roundRectPath<span class="operator">.</span>closeSubpath();

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> ellipsePath;
      ellipsePath<span class="operator">.</span>moveTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">50.0</span>);
      ellipsePath<span class="operator">.</span>arcTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">30.0</span><span class="operator">,</span> <span class="number">60.0</span><span class="operator">,</span> <span class="number">40.0</span><span class="operator">,</span> <span class="number">0.0</span><span class="operator">,</span> <span class="number">360.0</span>);

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> piePath;
      piePath<span class="operator">.</span>moveTo(<span class="number">50.0</span><span class="operator">,</span> <span class="number">50.0</span>);
      piePath<span class="operator">.</span>arcTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">30.0</span><span class="operator">,</span> <span class="number">60.0</span><span class="operator">,</span> <span class="number">40.0</span><span class="operator">,</span> <span class="number">60.0</span><span class="operator">,</span> <span class="number">240.0</span>);
      piePath<span class="operator">.</span>closeSubpath();

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> polygonPath;
      polygonPath<span class="operator">.</span>moveTo(<span class="number">10.0</span><span class="operator">,</span> <span class="number">80.0</span>);
      polygonPath<span class="operator">.</span>lineTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">10.0</span>);
      polygonPath<span class="operator">.</span>lineTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">30.0</span>);
      polygonPath<span class="operator">.</span>lineTo(<span class="number">90.0</span><span class="operator">,</span> <span class="number">70.0</span>);
      polygonPath<span class="operator">.</span>closeSubpath();

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> groupPath;
      groupPath<span class="operator">.</span>moveTo(<span class="number">60.0</span><span class="operator">,</span> <span class="number">40.0</span>);
      groupPath<span class="operator">.</span>arcTo(<span class="number">20.0</span><span class="operator">,</span> <span class="number">20.0</span><span class="operator">,</span> <span class="number">40.0</span><span class="operator">,</span> <span class="number">40.0</span><span class="operator">,</span> <span class="number">0.0</span><span class="operator">,</span> <span class="number">360.0</span>);
      groupPath<span class="operator">.</span>moveTo(<span class="number">40.0</span><span class="operator">,</span> <span class="number">40.0</span>);
      groupPath<span class="operator">.</span>lineTo(<span class="number">40.0</span><span class="operator">,</span> <span class="number">80.0</span>);
      groupPath<span class="operator">.</span>lineTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">80.0</span>);
      groupPath<span class="operator">.</span>lineTo(<span class="number">80.0</span><span class="operator">,</span> <span class="number">40.0</span>);
      groupPath<span class="operator">.</span>closeSubpath();

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> textPath;
      <span class="type"><a href="../qtgui/qfont.html">QFont</a></span> timesFont(<span class="string">&quot;Times&quot;</span><span class="operator">,</span> <span class="number">50</span>);
      timesFont<span class="operator">.</span>setStyleStrategy(<span class="type"><a href="../qtgui/qfont.html">QFont</a></span><span class="operator">::</span>ForceOutline);
      textPath<span class="operator">.</span>addText(<span class="number">10</span><span class="operator">,</span> <span class="number">70</span><span class="operator">,</span> timesFont<span class="operator">,</span> tr(<span class="string">&quot;Qt&quot;</span>));

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> bezierPath;
      bezierPath<span class="operator">.</span>moveTo(<span class="number">20</span><span class="operator">,</span> <span class="number">30</span>);
      bezierPath<span class="operator">.</span>cubicTo(<span class="number">80</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">80</span><span class="operator">,</span> <span class="number">80</span>);

      <span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> starPath;
      starPath<span class="operator">.</span>moveTo(<span class="number">90</span><span class="operator">,</span> <span class="number">50</span>);
      <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">1</span>; i <span class="operator">&lt;</span> <span class="number">5</span>; <span class="operator">+</span><span class="operator">+</span>i) {
          starPath<span class="operator">.</span>lineTo(<span class="number">50</span> <span class="operator">+</span> <span class="number">40</span> <span class="operator">*</span> std<span class="operator">::</span>cos(<span class="number">0.8</span> <span class="operator">*</span> i <span class="operator">*</span> M_PI)<span class="operator">,</span>
                          <span class="number">50</span> <span class="operator">+</span> <span class="number">40</span> <span class="operator">*</span> std<span class="operator">::</span>sin(<span class="number">0.8</span> <span class="operator">*</span> i <span class="operator">*</span> M_PI));
      }
      starPath<span class="operator">.</span>closeSubpath();

      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(rectPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(roundRectPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(ellipsePath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(piePath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(polygonPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(groupPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(textPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(bezierPath));
      renderAreas<span class="operator">.</span>push_back(<span class="keyword">new</span> RenderArea(starPath));

      fillRuleComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
      fillRuleComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(tr(<span class="string">&quot;Odd Even&quot;</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>OddEvenFill);
      fillRuleComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(tr(<span class="string">&quot;Winding&quot;</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>WindingFill);

      fillRuleLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Fill &amp;Rule:&quot;</span>));
      fillRuleLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(fillRuleComboBox);

      fillColor1ComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
      populateWithColors(fillColor1ComboBox);
      fillColor1ComboBox<span class="operator">-</span><span class="operator">&gt;</span>setCurrentIndex(fillColor1ComboBox<span class="operator">-</span><span class="operator">&gt;</span>findText(<span class="string">&quot;mediumslateblue&quot;</span>));

      fillColor2ComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
      populateWithColors(fillColor2ComboBox);
      fillColor2ComboBox<span class="operator">-</span><span class="operator">&gt;</span>setCurrentIndex(fillColor2ComboBox<span class="operator">-</span><span class="operator">&gt;</span>findText(<span class="string">&quot;cornsilk&quot;</span>));

      fillGradientLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Fill Gradient:&quot;</span>));
      fillGradientLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(fillColor1ComboBox);

      fillToLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;to&quot;</span>));
      fillToLabel<span class="operator">-</span><span class="operator">&gt;</span>setSizePolicy(<span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Fixed<span class="operator">,</span> <span class="type"><a href="qsizepolicy.html">QSizePolicy</a></span><span class="operator">::</span>Fixed);

      penWidthSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      penWidthSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">20</span>);

      penWidthLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Pen Width:&quot;</span>));
      penWidthLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(penWidthSpinBox);

      penColorComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
      populateWithColors(penColorComboBox);
      penColorComboBox<span class="operator">-</span><span class="operator">&gt;</span>setCurrentIndex(penColorComboBox<span class="operator">-</span><span class="operator">&gt;</span>findText(<span class="string">&quot;darkslateblue&quot;</span>));

      penColorLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Pen &amp;Color:&quot;</span>));
      penColorLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(penColorComboBox);

      rotationAngleSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      rotationAngleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">359</span>);
      rotationAngleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setWrapping(<span class="keyword">true</span>);
      rotationAngleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSuffix(QLatin1String(<span class="string">&quot;\xB0&quot;</span>));

      rotationAngleLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Rotation Angle:&quot;</span>));
      rotationAngleLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(rotationAngleSpinBox);

      connect(fillRuleComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type">int</span>))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(fillRuleChanged()));
      connect(fillColor1ComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type">int</span>))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(fillGradientChanged()));
      connect(fillColor2ComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type">int</span>))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(fillGradientChanged()));
      connect(penColorComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type">int</span>))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(penColorChanged()));

      <span class="keyword">for</span>(<span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>RenderArea<span class="operator">*</span><span class="operator">&gt;</span><span class="operator">::</span>iterator it <span class="operator">=</span> renderAreas<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> renderAreas<span class="operator">.</span>end(); it<span class="operator">+</span><span class="operator">+</span>) {
          connect(penWidthSpinBox<span class="operator">,</span> SIGNAL(valueChanged(<span class="type">int</span>))<span class="operator">,</span> <span class="operator">*</span>it<span class="operator">,</span> SLOT(setPenWidth(<span class="type">int</span>)));
          connect(rotationAngleSpinBox<span class="operator">,</span> SIGNAL(valueChanged(<span class="type">int</span>))<span class="operator">,</span> <span class="operator">*</span>it<span class="operator">,</span> SLOT(setRotationAngle(<span class="type">int</span>)));
      }

      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>topLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>;

      <span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>;
      <span class="keyword">for</span>(<span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>RenderArea<span class="operator">*</span><span class="operator">&gt;</span><span class="operator">::</span>iterator it <span class="operator">=</span> renderAreas<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> renderAreas<span class="operator">.</span>end(); it<span class="operator">+</span><span class="operator">+</span><span class="operator">,</span> i<span class="operator">+</span><span class="operator">+</span>)
          topLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(<span class="operator">*</span>it<span class="operator">,</span> i <span class="operator">/</span> <span class="number">3</span><span class="operator">,</span> i <span class="operator">%</span> <span class="number">3</span>);

      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>mainLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>;
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addLayout(topLayout<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">4</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillRuleLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillRuleComboBox<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillGradientLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillColor1ComboBox<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillToLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">2</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(fillColor2ComboBox<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">3</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(penWidthLabel<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(penWidthSpinBox<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(penColorLabel<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">0</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(penColorComboBox<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(rotationAngleLabel<span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="number">0</span>);
      mainLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(rotationAngleSpinBox<span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      setLayout(mainLayout);

      fillRuleChanged();
      fillGradientChanged();
      penColorChanged();
      penWidthSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">2</span>);

      setWindowTitle(tr(<span class="string">&quot;Painter Paths&quot;</span>));
  }

  <span class="type">void</span> Window<span class="operator">::</span>fillRuleChanged()
  {
      <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>FillRule rule <span class="operator">=</span> (<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>FillRule)currentItemData(fillRuleComboBox)<span class="operator">.</span>toInt();

      <span class="keyword">for</span> (<span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>RenderArea<span class="operator">*</span><span class="operator">&gt;</span><span class="operator">::</span>iterator it <span class="operator">=</span> renderAreas<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> renderAreas<span class="operator">.</span>end(); <span class="operator">+</span><span class="operator">+</span>it)
          (<span class="operator">*</span>it)<span class="operator">-</span><span class="operator">&gt;</span>setFillRule(rule);
  }

  <span class="type">void</span> Window<span class="operator">::</span>fillGradientChanged()
  {
      <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color1 <span class="operator">=</span> qvariant_cast<span class="operator">&lt;</span><span class="type"><a href="../qtgui/qcolor.html">QColor</a></span><span class="operator">&gt;</span>(currentItemData(fillColor1ComboBox));
      <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color2 <span class="operator">=</span> qvariant_cast<span class="operator">&lt;</span><span class="type"><a href="../qtgui/qcolor.html">QColor</a></span><span class="operator">&gt;</span>(currentItemData(fillColor2ComboBox));

      <span class="keyword">for</span> (<span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>RenderArea<span class="operator">*</span><span class="operator">&gt;</span><span class="operator">::</span>iterator it <span class="operator">=</span> renderAreas<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> renderAreas<span class="operator">.</span>end(); <span class="operator">+</span><span class="operator">+</span>it)
          (<span class="operator">*</span>it)<span class="operator">-</span><span class="operator">&gt;</span>setFillGradient(color1<span class="operator">,</span> color2);
  }

  <span class="type">void</span> Window<span class="operator">::</span>penColorChanged()
  {
      <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color <span class="operator">=</span> qvariant_cast<span class="operator">&lt;</span><span class="type"><a href="../qtgui/qcolor.html">QColor</a></span><span class="operator">&gt;</span>(currentItemData(penColorComboBox));

      <span class="keyword">for</span> (<span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span>RenderArea<span class="operator">*</span><span class="operator">&gt;</span><span class="operator">::</span>iterator it <span class="operator">=</span> renderAreas<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> renderAreas<span class="operator">.</span>end(); <span class="operator">+</span><span class="operator">+</span>it)
          (<span class="operator">*</span>it)<span class="operator">-</span><span class="operator">&gt;</span>setPenColor(color);
  }

  <span class="type">void</span> Window<span class="operator">::</span>populateWithColors(<span class="type"><a href="qcombobox.html">QComboBox</a></span> <span class="operator">*</span>comboBox)
  {
      <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> colorNames <span class="operator">=</span> <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span><span class="operator">::</span>colorNames();
      foreach (<span class="type"><a href="../qtcore/qstring.html">QString</a></span> name<span class="operator">,</span> colorNames)
          comboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(name<span class="operator">,</span> <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span>(name));
  }

  <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> Window<span class="operator">::</span>currentItemData(<span class="type"><a href="qcombobox.html">QComboBox</a></span> <span class="operator">*</span>comboBox)
  {
      <span class="keyword">return</span> comboBox<span class="operator">-</span><span class="operator">&gt;</span>itemData(comboBox<span class="operator">-</span><span class="operator">&gt;</span>currentIndex());
  }

</pre>
</div>
<!-- @@@painting/painterpaths/window.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
